package com.huawei.crm.sample.application.product.validator;

import com.huawei.crm.sample.application.product.dto.ProductDTO;

public class ProductValidator {
    public static void validateForCreate(ProductDTO productDTO) {
        if (productDTO == null) throw new IllegalArgumentException("商品参数不能为空");
        if (productDTO.getName() == null || productDTO.getName().isEmpty()) throw new IllegalArgumentException("商品名称不能为空");
        if (productDTO.getStock() < 0) throw new IllegalArgumentException("库存不能为负数");
        if (productDTO.getPrice() == null || productDTO.getPrice().signum() < 0) throw new IllegalArgumentException("价格不能为负数");
    }
} 